package call.count;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能：切面拦截是否成功的标记枚举
 *
 * @author baitao20
 * @date 2024/2/28 17:34
 **/
public enum ADVICE_SUCCESS_ENUM {

    /**
     * 拦截成功
     */
    SUCCESS(1, "拦截成功"),

    /**
     * 拦截失败
     */
    FAIL(2, "拦截失败");

    private final Integer value;

    private final String label;

    private static final Map<Integer, String> valueMap = new HashMap<>();

    private static final Map<Integer, ADVICE_SUCCESS_ENUM> enumMap = new HashMap<>();

    static {
        for (ADVICE_SUCCESS_ENUM item : ADVICE_SUCCESS_ENUM.values()) {
            valueMap.put(item.value, item.label);
            enumMap.put(item.value, item);
        }
    }

    ADVICE_SUCCESS_ENUM(Integer value, String label) {
        this.value = value;
        this.label = label;
    }

    public Integer intValue() {
        return this.value;
    }

    public String value() {
        return String.valueOf(this.value);
    }

    public String label() {
        return this.label;
    }

    public static String getLabelByValue(Integer value) {
        return valueMap.get(value);
    }

    public static ADVICE_SUCCESS_ENUM getEnumByValue(Integer value) {
        return enumMap.get(value);
    }
}
